using UnityEngine;

public class Shady : Enemy
{
    private GameObject explosivePrefab;
    private float growSpeed = 15f;
    private float maxSize = 6f;
    public ShadyGroundState GroundState { get; private set; }
    public ShadyIdleState IdleState { get; private set; }
    public ShadyMoveState MoveState { get; private set; }
    public ShadyBattleState BattleState { get; private set; }
    public ShadyStunnedState StunnedState { get; private set; }
    public ShadyAttackState AttackState { get; private set; }
    public ShadyDeadState DeadState { get; private set; }
    [Header("Shady spesifics")]
    public float battleMoveSpeed = 4f;

    protected override void Awake()
    {
        base.Awake();
        explosivePrefab = Resources.Load<GameObject>("Prefabs/ExplosiveController");
        GroundState = new(this, "idle");
        IdleState = new(this, "idle");
        MoveState = new(this, "move");
        BattleState = new(this, "moveFast");
        StunnedState = new(this, "stunned");
        AttackState = new(this, "attack");
        DeadState = new(this, "dead");
        StateMachine.Initialize(IdleState);
    }

    public override void SpeicalAttackTrigger()
    {
        GameObject obj = Instantiate(explosivePrefab, AttackPoint.position, Quaternion.identity);
        obj.GetComponent<ExplosiveController>().Setup(Stats, growSpeed, maxSize, attackCheckRadius);
        Rb.gravityScale = 0;

    }

    public override bool CanBeStunned()
    {
        if (canBeStunned)
        {
            StateMachine.ChangeTo(StunnedState);
            return true;
        }
        return false;
    }

    public override void Die()
    {
        base.Die();
        StateMachine.ChangeTo(DeadState);
    }
}
